package com.ruoyi.fantasy.service.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.huanzhidadi.fantasy.bean.domain.FantasyMapShop;
import com.ruoyi.common.utils.IdWorker;
import com.ruoyi.fantasy.domain.FantasyNpcPosition;
import org.springframework.stereotype.Service;
import com.ruoyi.fantasy.mapper.FantasyMapShopMapper;
import com.ruoyi.fantasy.service.IFantasyMapShopService;
import com.ruoyi.common.core.text.Convert;

import javax.annotation.Resource;

/**
 * 地图商店关系 服务层实现
 * 
 * @author wanghui
 * @date 2020-01-29
 */
@Service
public class FantasyMapShopServiceImpl implements IFantasyMapShopService 
{
	@Resource
	private FantasyMapShopMapper fantasyMapShopMapper;

	/**
     * 查询地图商店关系信息
     * 
     * @param id 地图商店关系ID
     * @return 地图商店关系信息
     */
    @Override
	public FantasyMapShop selectFantasyMapShopById(Long id)
	{
	    return fantasyMapShopMapper.selectFantasyMapShopById(id);
	}
	
	/**
     * 查询地图商店关系列表
     * 
     * @param fantasyMapShop 地图商店关系信息
     * @return 地图商店关系集合
     */
	@Override
	public List<FantasyMapShop> selectFantasyMapShopList(FantasyMapShop fantasyMapShop)
	{
	    return fantasyMapShopMapper.selectFantasyMapShopList(fantasyMapShop);
	}
	
    /**
     * 新增地图商店关系
     * 
     * @param fantasyMapShop 地图商店关系信息
     * @return 结果
     */
	@Override
	public int insertFantasyMapShop(FantasyMapShop fantasyMapShop)
	{
	    return fantasyMapShopMapper.insertFantasyMapShop(fantasyMapShop);
	}
	
	/**
     * 修改地图商店关系
     * 
     * @param fantasyMapShop 地图商店关系信息
     * @return 结果
     */
	@Override
	public int updateFantasyMapShop(FantasyMapShop fantasyMapShop)
	{
	    return fantasyMapShopMapper.updateFantasyMapShop(fantasyMapShop);
	}

	/**
     * 删除地图商店关系对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteFantasyMapShopByIds(String ids)
	{
		return fantasyMapShopMapper.deleteFantasyMapShopByIds(Convert.toStrArray(ids));
	}

	@Override
	public int deleteFantasyMapShop(FantasyMapShop fantasyMapShop) {
		return fantasyMapShopMapper.deleteFantasyMapShop(fantasyMapShop);
	}

	@Override
	public int deleteAllocShops(String mapId, String shopIds) {
		Long[] shopIdArray = Convert.toLongArray(shopIds);
		return fantasyMapShopMapper.deleteAllocShops(mapId, shopIdArray);
	}

	@Override
	public int insertAllocShops(String mapId, String shopIds) {
		String[] shopIdArray = Convert.toStrArray(shopIds);
		// 新增地图商店对应关系
		List<FantasyMapShop> list = new ArrayList<>();
		for (String shopId : shopIdArray)
		{
			FantasyMapShop fantasyMapShop = new FantasyMapShop();
			fantasyMapShop.setMapId(mapId);
			fantasyMapShop.setShopId(shopId);
			list.add(fantasyMapShop);
		}
		return fantasyMapShopMapper.batchAllocShops(list);
	}

}
